﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_AddExpertNews : System.Web.UI.Page
{
	private PX.File.FileComponent clsFileComp = new PX.File.FileComponent();		// 上传文件控制类
	private PX.UploadFile.UploadFileComponent clsUploadFileComp = new PX.UploadFile.UploadFileComponent();		// 上传文件内容控制类

	protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
		{
			TBDate.Text = System.DateTime.Now.ToShortDateString();
		}
	}

	protected override void OnInit(EventArgs e)
	{
		base.OnInit(e);

		clsFileComp.page = Page;
		clsUploadFileComp.page = Page;

		TBDate.Attributes.Add("onClick", "popUpCalendar(this, this, 'yyyy-mm-dd')");

		LBtnAdd.Click += new EventHandler(LBtnAdd_Click);
	}

	void LBtnAdd_Click(object sender, EventArgs e)
	{
		AddExpertNews();
	}

	/// <summary>
	/// 添加一个大师动态
	/// </summary>
	/// <returns></returns>
	private bool AddExpertNews()
	{
		PX.UploadFile.UploadFile clsUploadFileContent = new PX.UploadFile.UploadFile();
		PX.File.File clsFile = new PX.File.File();

		if (clsUploadFileComp.Add(FUploadExpertNews, clsUploadFileContent))
		{
			clsFile.DateTime = System.DateTime.Now.ToString();
			clsFile.DepartmentID = Convert.ToInt32(Session["LoginUserDepartmentID"]);
			clsFile.UserID = Convert.ToInt32(Session["LoginUserID"]);
			clsFile.ColumnID = 125;
			clsFile.FileID = clsUploadFileContent.ID;
			clsFile.ShowDate = TBDate.Text;
			clsFile.FileName = clsUploadFileContent.FileName;
			clsFile.Type = clsUploadFileContent.Type;
			if (clsFileComp.Add(clsFile))
			{
				Common.ShowMessageAlert.ShowMessage(Page, "上传成功！");
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
}